package com.plian.system.wrapper.pm.realproperty;

import com.plian.system.dto.pm.realproperty.RealPropertyDTO;
import com.plian.system.entity.pm.realproperty.RealProperty;
import com.plian.system.entity.yth.realproperty.House;
import com.plian.system.entity.yth.realproperty.Land;
import com.plian.system.mybatis.support.BaseWrapper;
import com.plian.system.vo.pm.realproperty.RealPropertyVO;
import com.plian.system.vo.pm.realproperty.RealPropertyYearInfoVO;
import com.plian.system.wrapper.util.CacheWrapperUtil;
import com.plian.system.wrapper.util.WrapperUtil;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;

import static com.plian.system.wrapper.util.WrapperConstant.*;

/**
 * 不动产登记信息表包装类,返回视图层所需的字段
 *
 * @author BladeX
 * @since 2021-06-01
 */
@Mapper(componentModel = SPRING, uses = {CacheWrapperUtil.class, WrapperUtil.class})
public interface RealPropertyWrapper extends BaseWrapper<RealProperty, RealPropertyDTO, RealPropertyVO> {

	/**
	 * Entity转VO
	 *
	 * @param entity /
	 * @return /
	 */
	@Override
	@Mappings(value = {
			@Mapping(source = "fillingUnitId", target = "fillingUnitName", qualifiedByName = ORG_ID_TO_NAME),
			@Mapping(source = "entrustUnitId", target = "entrustUnitName", qualifiedByName = ORG_ID_TO_NAME),
			@Mapping(source = "orgId", target = "orgName", qualifiedByName = ORG_ID_TO_NAME),
			@Mapping(source = "createUser", target = "createUserName", qualifiedByName = USER_ID_TO_NAME),
			@Mapping(source = "updateUser", target = "updateUserName", qualifiedByName = USER_ID_TO_NAME),
			@Mapping(source = "approvedUser", target = "approvedUserName", qualifiedByName = USER_ID_TO_NAME),

			@Mapping(source = "landNature", target = "landNatureName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "landUse", target = "landUseName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "houseStructure", target = "houseStructureName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "houseNature", target = "houseNatureName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "houseSource", target = "houseSourceName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "houseUse", target = "houseUseName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "disposalWay", target = "disposalWayName", qualifiedByName = DICT_CODE_TO_NAME)
	})
	RealPropertyVO entityToVO(RealProperty entity);

	@Mappings({
			@Mapping(source = "initialId", target = "realPropertyId")
	})
	RealPropertyYearInfoVO realPropertyVOToRealPropertyYearInfoVO(RealPropertyVO realPropertyVO);


	@Mappings({
			@Mapping(source = "reportOrgId", target = "fillingUnitId"),
			@Mapping(source = "belongUnitId", target = "orgId"),
			@Mapping(source = "name", target = "landName"),
			@Mapping(source = "address", target = "landLocatedPosition"),
			@Mapping(source = "takeTime", target = "landAcquisitionTime"),
			@Mapping(source = "landType", target = "landNature"),
			@Mapping(source = "landArea", target = "landTotalArea"),
			@Mapping(source = "entryValue", target = "landBookValue"),
			@Mapping(source = "confirmType", target = "landMadeSituation"),
			@Mapping(source = "unConfirmedReason", target = "landNoMadeReason"),
			@Mapping(source = "confirmedArea", target = "landMadeArea"),
			@Mapping(source = "unConfirmedArea", target = "landNoMadeArea"),
			@Mapping(source = "warrantor", target = "landWarrant"),
			@Mapping(source = "certNo", target = "landCardNumber"),
			@Mapping(source = "certDate", target = "landReleaseDate"),
			@Mapping(source = "remark", target = "landRemark"),
			@Mapping(source = "isRental", target = "isHaveRentArea"),
			@Mapping(source = "isFairValue", target = "isHaveFairValue"),
			@Mapping(source = "id", target = "dataSourceId")
	})
	RealProperty landToRealProperty(Land land);

	List<RealProperty> landToRealProperty(List<Land> landList);

	@Mappings({
			@Mapping(source = "reportOrgId", target = "fillingUnitId"),
			@Mapping(source = "belongUnitId", target = "orgId"),
			@Mapping(source = "name", target = "landName"),
			@Mapping(source = "address", target = "landLocatedPosition"),
			@Mapping(source = "takeTime", target = "landAcquisitionTime"),
			@Mapping(source = "landType", target = "landNature"),
			@Mapping(source = "landArea", target = "landTotalArea"),
			@Mapping(source = "entryValue", target = "landBookValue"),
			@Mapping(source = "confirmType", target = "landMadeSituation"),
			@Mapping(source = "unConfirmedReason", target = "landNoMadeReason"),
			@Mapping(source = "confirmedArea", target = "landMadeArea"),
			@Mapping(source = "unConfirmedArea", target = "landNoMadeArea"),
			@Mapping(source = "warrantor", target = "landWarrant"),
			@Mapping(source = "certNo", target = "landCardNumber"),
			@Mapping(source = "certDate", target = "landReleaseDate"),
			@Mapping(source = "remark", target = "landRemark"),
			@Mapping(source = "isRental", target = "isHaveRentArea"),
			@Mapping(source = "isFairValue", target = "isHaveFairValue"),
			@Mapping(source = "houseAddress", target = "houseLocatedPosition"),
			@Mapping(source = "struct", target = "houseStructure"),
			@Mapping(source = "houseType", target = "houseNature"),
			@Mapping(source = "houseArea", target = "houseTotalArea"),
			@Mapping(source = "houseEntryValue", target = "houseBookValue"),
			@Mapping(source = "powerType", target = "houseRightType"),
			@Mapping(source = "source", target = "houseSource"),
			@Mapping(source = "planUse", target = "houseUse"),
			@Mapping(source = "houseConfirmType", target = "houseMadeSituation"),
			@Mapping(source = "houseUnConfirmedReason", target = "houseNoMadeReason"),
			@Mapping(source = "houseConfirmedArea", target = "houseMadeArea"),
			@Mapping(source = "houseUnConfirmedArea", target = "houseNoMadeArea"),
			@Mapping(source = "carCount", target = "parkingNumber"),
			@Mapping(source = "certType", target = "documentType"),
			@Mapping(source = "houseWarrantor", target = "houseWarrant"),
			@Mapping(source = "houseCertNo", target = "houseCardNumber"),
			@Mapping(source = "houseCertDate", target = "houseReleaseDate"),
			@Mapping(source = "id", target = "dataSourceId")
	})
	RealProperty houseToRealProperty(House land);

	List<RealProperty> houseToRealProperty(List<House> houseList);

	RealProperty copyEntity(RealProperty entity);


}
